package collection;

import java.util.ArrayList;
import java.util.List;

public class ListDemo3 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<10;i++){
            list.add(i);
        }
        System.out.println(list);
        //[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

        List<Integer> subList = list.subList(3,8);
        System.out.println("sub:"+subList);
        //sub:[3, 4, 5, 6, 7]

        for (int i=0;i<subList.size();i++){
            subList.set(i,subList.get(i)*10);
        }
        System.out.println("sub:"+subList);
        //sub:[30, 40, 50, 60, 70]

        System.out.println(list);
        //[0, 1, 2, 30, 40, 50, 60, 70, 8, 9]

        list.subList(1,9).clear();
        System.out.println(list);
        //[0, 9]
    }
}
